src\Ginsa\SistemaBundle\Controller\FaqController.php line 92

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by Ginsa Informática S.A.
  4.  * Programador: Michael Ballester Granero
  5.  *
  6.  * Este archivo pertenece a la aplicación realizada por Ginsa Informática S.A..
  7.  * El código fuente de la aplicación incluye un archivo llamado LICENSE
  8.  * con toda la información sobre el copyright y la licencia.
  9.  */
  10. namespace App\Ginsa\SistemaBundle\Controller;
  11. use App\Ginsa\SistemaBundle\Entity\Modulos;
  12. use App\Ginsa\SistemaBundle\Entity\Preguntas;
  13. use App\Ginsa\SistemaBundle\Services\CheckLicenseService;
  14. use App\Ginsa\SistemaBundle\Singelton\ClienteActivo;
  15. use Symfony\Component\HttpFoundation\Request;
  16. use Symfony\Component\HttpFoundation\Response;
  17. class FaqController extends AbstractGinsaController
  18. {
  19.     /**
  20.      * Pantalla inicial del faq
  21.      * @param Request $request
  22.      * @param CheckLicenseService $checkLicenseService
  23.      * @return Response
  24.      */
  25.     public function index(Request $requestCheckLicenseService $checkLicenseService)
  26.     {
  27.         $session $request->getSession();
  28.         if ($session->get('base') == null$base '@GinsaSistema/base.html.twig';
  29.         else $base $session->get('base');
  30.         //Obtenemos el listado de modulos y despues le añadimos todas las preguntas que contiene, hasta un max de 4
  31.         $modulos $this->getDoctrine()->getManager()->getRepository(Modulos::class)->recientesByModulo();
  32.         foreach ($modulos as $key => $modulo) {
  33.             $modulos[$key]['preguntas'] = $this->getDoctrine()->getManager()->getRepository(Preguntas::class)->recientesByModulo($modulo['id'], 4);
  34.         }
  35.         return $this->render('@GinsaSistema/FAQ/faqIndex.html.twig', array(
  36.             'client' => ClienteActivo::getInstance()->getCliente(),
  37.             'licencia' => $checkLicenseService->compruebaLicenciaCliente(),
  38.             'base' => $base,
  39.             'modulos' => $modulos
  40.         ));
  41.     }
  42.     /**
  43.      * Mostramos la pantalla del modulo, donde se muestra un acordeon por categorias y dentro las distintas preguntas
  44.      * @param Request $request
  45.      * @param CheckLicenseService $checkLicense
  46.      * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  47.      */
  48.     public function modulosShow(Request $requestCheckLicenseService $checkLicense)
  49.     {
  50.         $session $request->getSession();
  51.         if ($session->get('base') == null$base '@GinsaSistema/base.html.twig';
  52.         else $base $session->get('base');
  53.         $modulos $this->getDoctrine()->getManager()->getRepository(Modulos::class)->obtenerBySlug($request->get('moduloSlug'));
  54.         return $this->render('@GinsaSistema/FAQ/faqModulosShow.html.twig', array(
  55.             'client' => ClienteActivo::getInstance()->getCliente(),
  56.             'licencia' => $checkLicense->compruebaLicenciaCliente(),
  57.             'base' => $base,
  58.             'modulos' => $modulos
  59.         ));
  60.     }
  61.     /**
  62.      * Cuando seleccionamos
  63.      * @param Request $request
  64.      * @param CheckLicenseService $checkLicense
  65.      * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  66.      */
  67.     public function preguntasShow(Request $requestCheckLicenseService $checkLicense)
  68.     {
  69.         $session $request->getSession();
  70.         if ($session->get('base') == null$base '@GinsaSistema/base.html.twig';
  71.         else $base $session->get('base');
  72.         $pregunta $this->getDoctrine()->getManager()->getRepository(Preguntas::class)->obtenerBySlug($request->get('slug'));
  73.         return $this->render('@GinsaSistema/FAQ/faqPreguntaShow.html.twig', array(
  74.             'client' => ClienteActivo::getInstance()->getCliente(),
  75.             'licencia' => $checkLicense->compruebaLicenciaCliente(),
  76.             'base' => $base,
  77.             'pregunta' => $pregunta
  78.         ));
  79.     }
  80.     /**
  81.      * Buscamos las preguntas por los diferentes titulos y mostramos el listado con el resultado
  82.      * @param Request $request
  83.      * @param CheckLicenseService $checkLicense
  84.      * @return \Symfony\Component\HttpFoundation\Response
  85.      */
  86.     public function buscarPreguntas(Request $requestCheckLicenseService $checkLicense)
  87.     {
  88.         $session $request->getSession();
  89.         if ($session->get('base') == null$base '@GinsaSistema/base.html.twig';
  90.         else $base $session->get('base');
  91.         $preguntas $this->getDoctrine()->getManager()->getRepository(Preguntas::class)->obtenerByTitulo($request->query->get('buscar'));
  92.         return $this->render('@GinsaSistema/FAQ/faqResultadoBusqueda.html.twig', array(
  93.             'client' => ClienteActivo::getInstance()->getCliente(),
  94.             'licencia' => $checkLicense->compruebaLicenciaCliente(),
  95.             'base' => $base,
  96.             'preguntas' => $preguntas,
  97.             'buscando' => $request->query->get('buscar')
  98.         ));
  99.     }
  100. }